﻿<?php 

/**
* Базовый класс для табличных алиасов
*/

class Queries{
	protected $db;
	
	private function UseTableAlias($tables){
		$result = $tables;
		if(is_array($tables)){
			foreach($tables as $key=>$table){
				if(isset($this->tables[$table])) $result[$key]=$this->tables[$table];
			}
		}elseif(isset($this->tables[$tables])) $result = $this->tables[$tables];
		return $result;
	}
	
	public function AddQuery($q,$param=NULL,$tablenames=NULL){
		$tablenames = $this->UseTableAlias($tablenames);
		return $this->db->AddQuery($q,$param,$tablenames);		
	}

	public function Execute(){
		return $this->db->Execute();
	}
	
	public function __construct($db){
		$this->db=$db;
	}
}